<template>
  <div
    class="app-container"

  >
    <div

    >
      <el-form
        ref="form"
        size="small"
        :model="form"
        :rules="rules"
        label-position="left"
        label-width="120px"
		style="background: rgb(255, 255, 255);width: 600px;margin: 0px 0px 0px 500px;border-radius: 10px;"
      >
        <el-tabs v-model="activeName">
          <el-tab-pane
            style="padding-top: 10px"
            label="微信小程序配置"
            name="微信小程序配置"
          >
            <el-row>
              <el-col :span="24">
                <el-form-item label="原始ID" style="margin: 0px 0px 22px 60px;">
                  <el-input
                    v-model="form.original"
                    auto-complete="off"
                    clearable
                    placeholder="请输入原始ID"
					style="width: 300px;"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="AppId" style="margin: 0px 0px 22px 60px;">
                  <el-input
                    v-model="form.app_id"
                    auto-complete="off"
                    clearable
                    placeholder="请输入AppId"
					style="width: 300px;"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="AppSecret" style="margin: 0px 0px 22px 60px;">
                  <el-input
                    v-model="form.secret"
                    auto-complete="off"
                    clearable
                    placeholder="请输入AppSecret"
					style="width: 300px;"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <!-- <el-row>
              <el-col :span="24">
                <el-form-item label="uniacid 和 acid">
                  {{ form.uniacid }}
                </el-form-item>
              </el-col>
            </el-row> -->
          </el-tab-pane>

          <el-tab-pane
            style="padding-top: 10px"
            label="抖音小程序配置"
            name="抖音小程序配置"
          >
            <el-row>
              <el-col :span="24">
                <el-form-item label="AppId" style="margin: 0px 0px 22px 60px;">
                  <el-input
                    v-model="form.ttapp_id"
                    auto-complete="off"
                    clearable
                    placeholder="请输入AppId"
					style="width: 300px;"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="Secret" style="margin: 0px 0px 22px 60px;">
                  <el-input
                    v-model="form.ttsecret"
                    auto-complete="off"
                    clearable
                    placeholder="请输入Secret"
					style="width: 300px;"
                  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane
            style="padding-top: 10px"
            label="公众号配置"
            name="公众号配置"
          >
            <el-row>
              <el-col :span="24">
                <el-form-item label="AppId" style="margin: 0px 0px 22px 60px;">
                  <el-input
                    v-model="form.weixin_offiaccount_app_id"
                    auto-complete="off"
                    clearable
                    placeholder="请输入AppId"
					style="width: 300px;"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="AppSecret" style="margin: 0px 0px 22px 60px;">
                  <el-input
                    v-model="form.weixin_offiaccount_secret"
                    auto-complete="off"
                    clearable
                    placeholder="请输入AppSecret"
					style="width: 300px;"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="Token" style="margin: 0px 0px 22px 60px;">
                  <el-input
                    v-model="form.token"
                    auto-complete="off"
                    clearable
                    placeholder="请输入Token"
					style="width: 300px;"
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="EncodingAESKey" style="margin: 0px 0px 22px 60px;">
                  <el-input
                    v-model="form.aes_key"
                    auto-complete="off"
                    clearable
                    placeholder="请输入EncodingAESKey"
					style="width: 300px;"
                  />
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
          <!-- <el-tab-pane style="padding-top:10px" label="师傅端小程序配置" name="师傅端小程序配置"> -->
          <!-- <el-row>
              <el-col :span="24">
                <el-form-item label="原始ID">
                  <el-input v-model="form.techoriginal" auto-complete="off" clearable placeholder="请输入原始ID" />
                </el-form-item>
              </el-col>
            </el-row> -->
          <!-- <el-row>
              <el-col :span="24">
                <el-form-item label="AppId">
                  <el-input v-model="form.techapp_id" auto-complete="off" clearable placeholder="请输入AppId" />
                </el-form-item>
              </el-col>
            </el-row> -->
          <!-- <el-row>
              <el-col :span="24">
                <el-form-item label="AppSecret">
                  <el-input v-model="form.techsecret" auto-complete="off" clearable placeholder="请输入AppSecret" />
                </el-form-item>
              </el-col>
            </el-row> -->
          <!-- <el-row>
              <el-col :span="24">
                <el-form-item label="uniacid 和 acid">
                  {{ form.uniacid }}
                </el-form-item>
              </el-col>
            </el-row> -->
          <!-- </el-tab-pane> -->
        </el-tabs>
        <el-form-item>
          <el-button size="small" type="primary" @click="submit"
            >保存设置</el-button
          >
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  name: "Configminiprogram",
  components: {},
  data() {
    return {
      form: {},
      loading: false,
      activeName: "微信小程序配置",
      rules: {},
    };
  },
  mounted() {
    this.$api.post("/config/getInfo", { mo: "miniprogram" }).then((res) => {
      this.form = JSON.stringify(res.data) == "[]" ? {} : res.data;
      this.setDefaultVal("keyword");
    });
  },
  methods: {
    submit() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.loading = true;
          this.$api
            .post("/config/update", this.form)
            .then((res) => {
              this.$message({ message: "操作成功", type: "success" });
            })
            .catch(() => {
              this.loading = false;
            });
        }
      });
    },
    setDefaultVal(key) {
      if (this.form[key] == null || this.form[key] == "") {
        this.form[key] = [];
      }
    },
  },
};
</script>
